package com.jbit.springboot04.config;

import com.jbit.springboot04.pojo.Department;
import com.jbit.springboot04.pojo.Employee;
import jdk.internal.instrumentation.InstrumentationMethod;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration
public class MyConfig {

    @Bean
    public Department department(){
        Department department = new Department();
        department.setDeptNo("10000");
        department.setDeptName("人力资源部");
        return department;
    }
    //当我想要接收外部的一个bean时,直接方法传参即可,不用考虑对象从哪来
    @Bean
    public Employee employee1(Department department){
        Employee employee = new Employee();
        employee.setName("张三");
        employee.setDepartment(department);
        return employee;
    }

//    public void init(){
//        System.out.println("在指定bean创建前执行");
//    }
//
//    public void destroy(){
//        System.out.println("在指定bean销毁后执行");
//    }

    @Bean
    public Employee employee2(){
        Employee employee = new Employee();
        employee.setName("李四");
        employee.setDepartment(department());
        return employee;
    }


}
